from hz_utils.parse import extract_datetime
from datetime import datetime


def test_pat1():
    text = "发布日期 2024年3月1日"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 00:00:00", "%Y-%m-%d %H:%M:%S"
    )

def test_pat2():
    text = "发布日期 2024年3月1号"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 00:00:00", "%Y-%m-%d %H:%M:%S"
    )

def test_pat3():
    text = "发布日期 2024年3月1日 12:31"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 12:31:00", "%Y-%m-%d %H:%M:%S"
    )

def test_pat4():
    text = "发布日期 2024年3月1日 12:31:43"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 12:31:43", "%Y-%m-%d %H:%M:%S"
    )

def test_pat5():
    text = "发布日期 2024年03月01日 12:31:43"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 12:31:43", "%Y-%m-%d %H:%M:%S"
    )

def test_pat6():
    text = "发布日期 2024/03/01 12:31:43"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 12:31:43", "%Y-%m-%d %H:%M:%S"
    )

def test_pat7():
    text = "发布日期 2024/03/01  12:31:43"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 12:31:43", "%Y-%m-%d %H:%M:%S"
    )

def test_pat8():
    text = "发布日期 2024/3/1  12:31:43"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 12:31:43", "%Y-%m-%d %H:%M:%S"
    )

def test_pat9():
    text = "发布日期 2024/3-1  12:31:43"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 12:31:43", "%Y-%m-%d %H:%M:%S"
    )

def test_pat10():
    text = "发布日期 2024-3-1  12:31:43"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 12:31:43", "%Y-%m-%d %H:%M:%S"
    )

def test_pat11():
    text = "发布日期 2024-3-1 "
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 00:00:00", "%Y-%m-%d %H:%M:%S"
    )

def test_pat12():
    text = "发布日期 -2024-  3/1 "
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 00:00:00", "%Y-%m-%d %H:%M:%S"
    )

def test_pat13():
    text = "发布日期 -2024-  3/1 14:42"
    assert extract_datetime(text) == datetime.strptime(
        "2024-03-01 14:42:00", "%Y-%m-%d %H:%M:%S"
    )

def test_pat14():
    text = "发布日期"
    assert extract_datetime(text) is None